//
//  Edit_TextView.m
//  SoundPill
//
//  Created by 宋旭东 on 15/3/3.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "Edit_TextView.h"

@interface Edit_TextView ()

@end

@implementation Edit_TextView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createViews];
    }
    return self;
}

- (void)createViews
{
    self.textLabel = [[UILabel alloc] initWithFrame:self.frame];
    _textLabel.textAlignment = NSTextAlignmentCenter;
    _textLabel.numberOfLines = 0;
    _textLabel.lineBreakMode = NSLineBreakByWordWrapping;
    _textLabel.textColor = [UIColor whiteColor];
//    _textLabel.font = [UIFont systemFontOfSize:18];
//    _textLabel.adjustsFontSizeToFitWidth = YES;
//    _textLabel.minimumScaleFactor = 12;
    [self addSubview:_textLabel];
}
- (void)layoutSubviews{
    [super layoutSubviews];
    _textLabel.frame = self.bounds;
}
- (void)setLabelText:(NSString *)text{
    UIFont *font = [UIFont fontWithName:@"Arial" size:16];
    _textLabel.font = font;
    _textLabel.text = text;
    CGSize deSize = [_textLabel sizeThatFits:CGSizeMake([UIScreen mainScreen].bounds.size.width * 0.423,CGFLOAT_MAX)];
    self.frame = CGRectMake(0, self.bounds.origin.y + self.bounds.size.height - deSize.height - 20, deSize.width + 20, deSize.height + 5);
    _textLabel.frame = CGRectMake(10, 0, deSize.width, deSize.height + 5);
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
